<?php

/**
 * This is the model class for table "{{tuan_user}}".
 *
 * The followings are the available columns in table '{{tuan_user}}':
 * @property integer $ztu_id
 * @property integer $zm_id
 * @property integer $zpt_id
 * @property string $zo_id
 * @property integer $ztu_status
 * @property string $ztu_hash
 * @property integer $inputtime
 */
class TuanUser extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return TuanUser the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{tuan_user}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zm_id, zpt_id, ztu_status, inputtime', 'numerical', 'integerOnly'=>true),
			array('zo_id', 'length', 'max'=>20),
			array('ztu_hash', 'length', 'max'=>32),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ztu_id, zm_id, zpt_id, zo_id, ztu_status, ztu_hash, inputtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
				'member'=>array(self::BELONGS_TO, 'Member', 'zm_id'),
				'order'=>array(self::BELONGS_TO, 'Order', 'zo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ztu_id' => 'Ztu',
			'zm_id' => 'Zm',
			'zpt_id' => 'Zpt',
			'zo_id' => 'Zo',
			'ztu_status' => 'Ztu Status',
			'ztu_hash' => 'Ztu Hash',
			'inputtime' => 'Inputtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search($type=10)
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ztu_id',$this->ztu_id);
		$criteria->compare('zm_id',$this->zm_id);
		$criteria->compare('zpt_id',$this->zpt_id);
		$criteria->compare('zo_id',$this->zo_id,true);
		$criteria->compare('ztu_status',$this->ztu_status);
		$criteria->compare('ztu_hash',$this->ztu_hash,true);
		$criteria->compare('inputtime',$this->inputtime);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
			'pagination'=>array(
					'pageSize'=>$type,
			),
		));
	}
}